using Microsoft.Phone.Controls.Maps.AutomationPeers;
using System;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Automation.Peers;
using System.Windows.Controls;
namespace Microsoft.Phone.Controls.Maps.Overlays
{
	[TemplatePart(Name = "ZoomIn", Type = typeof(Button)), TemplatePart(Name = "ZoomOut", Type = typeof(Button))]
	public class ZoomBar : Overlay
	{
		internal const string ZoomInElementName = "ZoomIn";
		internal const string ZoomOutElementName = "ZoomOut";
		private Button zoomIn;
		private Button zoomOut;
		public event EventHandler<MapCommandEventArgs> ZoomMap
		{
			[MethodImpl(32)]
			add
			{
				this.ZoomMap = (EventHandler<MapCommandEventArgs>)Delegate.Combine(this.ZoomMap, value);
			}
			[MethodImpl(32)]
			remove
			{
				this.ZoomMap = (EventHandler<MapCommandEventArgs>)Delegate.Remove(this.ZoomMap, value);
			}
		}
		public ZoomBar()
		{
			base.set_DefaultStyleKey(typeof(ZoomBar));
			this.zoomIn = new Button();
			this.zoomOut = new Button();
		}
		~ZoomBar()
		{
			this.ZoomMap = null;
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.zoomIn = (base.GetTemplateChild("ZoomIn") as Button);
			this.zoomOut = (base.GetTemplateChild("ZoomOut") as Button);
			if (this.zoomIn != null)
			{
				this.zoomIn.add_Click(new RoutedEventHandler(this.ZoomIn_Click));
			}
			if (this.zoomOut != null)
			{
				this.zoomOut.add_Click(new RoutedEventHandler(this.ZoomOut_Click));
			}
			base.FireTemplateApplied();
		}
		private void ZoomIn_Click(object sender, RoutedEventArgs e)
		{
			this.OnZoomMap(new ZoomMapCommand(true));
		}
		private void ZoomOut_Click(object sender, RoutedEventArgs e)
		{
			this.OnZoomMap(new ZoomMapCommand(false));
		}
		protected virtual void OnZoomMap(ZoomMapCommand command)
		{
			EventHandler<MapCommandEventArgs> zoomMap = this.ZoomMap;
			if (command != null && zoomMap != null)
			{
				zoomMap.Invoke(this, new MapCommandEventArgs(command));
			}
		}
		protected override AutomationPeer OnCreateAutomationPeer()
		{
			return new BaseAutomationPeer(this, "ZoomBar");
		}
	}
}
